<?php
session_start();
$username=(isset ($_POST['username'])) ? trim($_POST['username']):'';
$password=(isset ($_POST['password'])) ? $_POST['password'] : '';
$redirect=(isset ($_REQUEST[redirect])) ? $_REQUEST['redirect'] : '../Administrator/Default.php';
if(isset ($_POST['submit'])){
    if(!isset ($_SESSION['logged'])||$_SESSION['logged']!=1){
        if(!empty ($_POST['username']) && $_POST['username']=='admin' &&
                !empty ($_POST['password']) && $_POST['password']=='vien'){
            $_SESSION['username']=$username;
            $_SESSION['logged']=1;
            header('URL=' . $redirect);
            echo '<p>You will be redirected to you original page request. </p>';
            echo '<p>Trinh duyet se tu dong chuyen toi '.
            'Trang, <a href="' . $redirect .'">Click Here</a>.</p>';
            die ();
                }  else {
                    $_SESSION['username']='';
                    $_SESSION['logged']=0;
                    
                    $error='<p><strong>Ban nhap khong dung username hoac pass'.
                    'Moi ban dang ky</strong>Tai Day<a href="regiser.php">Clck here'.
                    'De Dang Ky</a>Neu ban chua co tai khoan.</p>';
                }
    }
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <link href="../css/style_admin.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <?php
        // put your code here
        ?>
        <center>
            <div id="login">
            <h3>Đăng Nhập Vào Trang Admin</h3>
            <form action="login.php" method="post">
            <label id="lb-ten_dang_nhap">Username:</label>
            <input id="inp-ten_danh_nhap"  type="text" name="username"/>
            <label id="lb-pass_dang_nhap" >Password:</label>
            <input id="inp-pass_dang_nhap" type="password" name="password" />
            <input id="login_submit" type="submit" name="submit" value="Đăng Nhập"/>
            </form>
            <p style="margin-top:150px;">Copyright@ Công Viên All rights reserved.</p>
            </div>
    </center>
    </body>
</html>
